package com.apes.fn.server.productRequire;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.api.SpringManager;
import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.jpa.tuple.date.DateTime;
import com.apes.framework.plugin.outbox.OutboxEventService;
import com.apes.framework.plugin.outbox.OutboxSubscriber;
import com.apes.framework.plugin.outbox.annotation.OutBoxExclude;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@OutBoxExclude
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DumpLog.CONST_TABLE_NAME)
public class DumpLog extends Model {
    public static final String CONST_TABLE_NAME = "stock_dump_log";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "转储日志")
    @Comment("消息编号")
    private String id;

    @Column(name = "aggregate_id", length = 255)
    @Comment("聚合根ID")
    private String aggregateId; //受给定事件影响的聚合根的id

    @Column(name = "aggregate_type", length = 128)
    @Comment("聚合根类型")
    private String aggregateType; //与给定事件相关的聚合根的类型

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "transfer_content", columnDefinition = "CLOB")
    @Comment("转储内容")
    private String transferContent;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "cross_content", columnDefinition = "CLOB")
    @Comment("调拨内容")
    private String crossContent;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "error", columnDefinition = "CLOB")
    @Comment("错误消息")
    private String error;


    @Column(name = "handled", columnDefinition = "NUMBER(10) default 0")
    @Comment("遗漏消息处理标记：0-未处理；1-已处理")
    private Integer handled = 0;
}
